/**
 * 手写bind方法
 * 1、定义myBind方法
 * 2、设置this并调用原函数
 * 3、接受剩余参数并返回结果
 */

Function.prototype.myBind = function (ctx, ...rest) {
    return (...argus) => {
        return this.call(ctx, ...rest, ...argus)
    }
}


const person = {
    name: 'jhy'
  }
function func(numA, numB, numC, numD) {
    console.log(this)
    console.log(numA, numB, numC, numD)
    return numA + numB + numC + numD
}
const bindFunc = func.myBind(person, 1, 2)
const res = bindFunc(3, 4)
console.log('返回值为:', res)